This is a documentation for describing the functionality added in the educated reality project
To build the application the following steps have to be performed:
Click player settings
Make sure the Company name + product name + version are correct and support (they should be in the Company.Name.Version)
Make sure the Configuration/Scripting Backend is set to mono
Go back and click build
The result should contain an exe, when you want to deliver the application you should zip the whole folder and unzip it on the client.
Click player settings
Click Android and click SwithPlatform (It will take some time to load and prepare everything)
Click Build
The result should be an apk you can install on quest/go.
To use the network functionality Photon folder was added.
All the custom scripts are added in the Assets/Scripts folder
This script is used for identifying a TalkingPoint and should be present on each plane you want to display in the machine. Each Talking point has to contain a PhotonTransformView and PhotonView component and has to have the meshRenderer component turned of instead of the first one like in the following picture:
This script is used to go through all the talking points. It has a list of talking points as input. When the button is pressed one item from the list will have the MeshRenderer component enabled while all the others disabled.
This script is used to reset the initial position of all the objects from the Card list. It takes as input a list of objects, saves their initial position. When pressed all the items from list will be moved to the initial position.
This script is for transfering the position of an object through the network. It should be present on all the object you want to share for all the members of the network.
The object should look like this.
The network player is a prefab locate at:
Assets\Photon\PhotonVoice\Demos\DemoVoiceMinimal\Resources
This prefab is created when the player connects. Once the player connects this prefab is created and the scripts tells the object to link itself to the VRRig component (to the head). In case you want to change the avatar just modify the prefab to use a head instead of the red cube.
This component is located in the scene and is responasible for connecting to the network and instatiating the network player.
More scripts were added :
The animal machine contains 2 canvases
For the ray to interact with the button there has to be a rigid body on the button as well as a collider.
On the button there are 2 scripts:
The animal selection button has a list of words that can be displayed on the machine. You can add as many animal names as you like.
In order for the script to work the Text field on the Animal Selection Button has to contain the text ui element from the AnimalNameCanvas (That is the text used to display the animal name).
This machines is synced through the network by using punRPC procedures which are like a signal that is sent to all the clients. When the button is pressed a signal is sent to every other animal machine for all the clients with the current word index and everybody updates their machine.
On the video player component a script called MoviesHolder was added so you can add a list of movies somebody can go through.
In our example we have videos in Asset folder and we dragged and droped them on the Movies field.
The VideoPlayer field has to contain the video player component from the object and the current movie index is just informative(do not change that it should always be 0).
In order to interact with the video player there are 3 canvases each holding a button added
Each button has a Movie Controller script attached that holds logic for interacting with the video player. Each button has it's own operation that executes when you click on it and you can see it on the OnClick event list.
NOTE: For the StartStop button we added A stop and a start image so when you click on it the image changes accordingly, those are not neccesary for other buttons.
The buttons work the same as other interaction buttons, having a rigid body, a collider and the interaction button script.
In order for the reticle to change size when you hover over a button, the name of the button has to contain "Button" in it.
The network part is the same as the animal button where every time you click on a movie button it sends a signal to all the other clients connected with the current movie index. Each client updates accordingly on his side the movie that is playing.
Those produce no effect on the application unless for android build. When you build the android version make sure to remove the LevelSelection (isLoading) lines before, (you can remove them is they are (not loaded), if they are is loading, close unity and open again, or just open the LevelSelection scene)
Updates
We added 3 new scenes and this is the current order of the scenes. Order is really important and should be respected because based on order we load our scenes.
Is the first scene of the game, it shows a random quote then waits for 5 seconds then loads LevelSelection. Here there is one very important component that is present in all scenes called LevelLoader.
LevelLoader is big black canvas with a image covering the screen. After the scene starts the image has an animation to fade away so the user can see the real world. This component is also responsable for loading the scenes in the game, this is done via the code.
We use a coroutine that starts the scene loading before actual load so we won't have a stutter in the transition. First the StartLoading is invoked with the scenenNumber we have to know then when we want to perform the actual loading we set ready = true;
IMPORTANT IS TO ALWAYS HAVE THIS ACTIVE ON EACH SCENE (Note: you can deactivate it while working in the scene, but have to make sure that is enabled when you build the application)
The other script in this scene is the quotes loader. This scripts reads quotes from a very big json full of quotes and selects a random one to display
The json file is located at Asset/Resources/quotes.json and has a structure where a quote is comprised of a quoteText and a quoteAuthor.
If you'd like to use your own quotes, i suggest to either let me help if you want to make a conversion from a different format or use the quotes-short.json instead and add them there.
For that you have to change something in the code : replace "quotes" with "quotes-short".
This is the scene where the player can create/join the room. After the players creates/joins a room the the next scene loaded would be either
The levelSelection scene has the following components in place:
This is very important to know, the PlayerData object is used for storing UI information that was selecting and passing it to the main room so we know what to load, where to connect, what our name was.
Every UI action saves information by calling the SetData method and retrieves information by calling GetData. The whole component is flexible and dinamic so we can add more information on the object that can be set before, or during the player gametime. Since this object will be loaded in the room scenes we have to make sure the PlayerData component remains active.
The menu manager is a component responsable of registering the canvases we have in our scene. It makes sure that there is always only 1 canvas loaded in the scene and we can navigate between them. Some buttons use the MenuManager to enable only a precise canvas that will be activated.
The component always knows to store the previous menu loaded so we can always go back
This is a key component in the UI selection because is enable coordonation and loading of desired menus.
There are several canvases in the scene :
This is the first canvas and should be the only one enabled when the scene starts. All the other canvases have to be closed. This is a simple one, it has 2 buttons (Create/Join). When create is pressed it loads the create_room_canvas when the join is pressed it loads the join_room canvas.
This is the canvas used for creating a room. There are 3 fields added and some validation for each field to make sure the data is correct. You can also a component that acts like a carrousel and goes through the room images. To make it work we can add a list of images and the name of the image is the room type name that will be saved in photon (In theory if we name this images the room index in the build settings we should be able to add easily multiple rooms)
After the data is filled and the room selected when create is pressed a new room is created and it will lead you to the create character canvas
This the menu used for joining a room, it has a simple validation to make sure the data si filled and that the room exists when you click join. After join is clicked it will load the create character canvas.
The create character canvas is the place where the player can customize his character. It has a name input with a simple validation.
There is one more important component here called the BodySelectionScript
In order to select a body part there are 2 containers that hold all the possible body parts :
The scripts take as input a list of those body parts that can be selected and makes sure to keep only 1 active.
In order to add a new Body/Head you have to add a similar head/body under HeadParent/BodyParent -> disable it -> and then drag and drop it in the body parts list of the desired BodySelectionScripts
Since photon doesn't store information like rooms created after the session is closed we have added a mongoDb database hosted in singapore
We use this database to store information in the form of EducatedRealityRoom object, more data can be added to the object.
Some changes were performed on the room scenes and here is the structure of the room scenes now:
I grouped the machines under one object to clean it up a bit, and also the video players. For the video players all of them can use the same script the same as i did in the rooms.
3 new objects were added in the scene and have to be present in all the rooms the player will join:
This script is used to read the room name + room password and provide a room name we can use to create a room in photon. Because of photon limitation the rooms we create are all in the following format roomname-roompassword (Example: roomName = test | roomPassowrd = link => photon room name = test-link).
This scripted is used both by the voice connection and by the player connection to join the correct room.
This component is responsable to create the head and the body for each player and send them to the network once the player connected. You will notice that to make sure the head and the head will fit and will look nice we created some containers for the body and for the head. The script needs to know those containers so it instatiates them in the correct place. To experiment with new head or body you can just drag them in the correct place and see if they fit, then disable them when you want to build.
This script also loads the player name above it's head. The name is loaded under the body container because we want it stable as we move and not move with the head. The object instatiated is also present in the scene to test and is called Name. You can see it under BodyContainer. The name is a canvas that has a text that is being populated when the player connects.
I will make a specific section for this but to bodies and heads are loaded from :
If you want a new body or a head you have to add a similar object in that location with name Body/Head and a new number.
Another important component is the network disconnector. Since we have multiple scenes loading asyncronously and also we can go back and forward between scenes there are scripts that are not destroyed between scenes like the VoiceConnectionAndRecorder. This script is responsable for connecting us to the network. The networkDisconnector is used to destroy this object and to load the first scene of the game after that. This is the same component that is used when the back button is pressed in the menu.
When creating a new room make sure to have all those set up (If you copy/paste the rooms then it should be ok)